package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

// 默认放图书最后一个
public class AddOperation implements IOperation{
    public void work(BookList bookList){
        System.out.println("新增图书");//每一个操作都有这样的操作方法 可以把这些方法抽象出一个接口

        System.out.println("请输入图书的名字");
        String name = scanner.nextLine();
        System.out.println("请输入图书的作者");
        String author = scanner.nextLine();
        System.out.println("请输入图书的价格");
        double price = scanner.nextDouble();
        scanner.nextLine();//吸收回车符
        System.out.println("请输入图书的类型");
        String type = scanner.nextLine();
//      new一个实例化的书
        Book book = new Book(name,author,price,type);

        int count = bookList.getCount();
        bookList.setBook(count,book);
        bookList.setCount(count+1);
        System.out.println("新增成功");
    }
}